<%@ page language="java" import="java.util.*,pojo.*,service.*,base.*,java.text.*,java.sql.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>菜品信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="../jquery/jquery-1.6.1.js"></script>
	      <script src="../bootstrap/js/bootstrap.js" type="text/javascript"></script>
<script type="text/javascript">
function add(url){
  location.href=url;
 }
$(function(){
	$("#review").click(function(){
	    $('#myModal').modal('show')
	});
});
</script>
<script type="text/javascript">
$(function(){
	$("#ok").click(function(){
	var level=$("input:checked");
	var content=$("#review").val();
	if(level.size()<3){
	alert("请对菜品的色香味进行评价！！！");
	return false;
	}
    else if(content==""){
	alert("请输入具体评价内容");
	return false;
	}
    else $("#form").submit();
	
	})
})


</script>
  </head>
  <body onload="textnum();">
  <div class="navbar navbar-inverse navbar-fixed-top">
       <div class="navbar-inner">
           <div class="container-fluid">
                   <a class="brand" href="index.jsp">白金汉宫网上订餐</a>
              <div class="nav-collapse collapse">
         
                  <ul class="nav">
                    <li class="active">
                        <a href="#">主页</a>
                    </li>
                  </ul>
      <p class="navbar-text pull-right">
<%
        
		String username = (String)session.getAttribute( "name" );
		CartService cs= new CartService();
		if ( username == null || username == "" )
		{
%>
<a class="navbar-link" href="login.jsp">登录</a>&nbsp;&nbsp;&nbsp;<a class="navbar-link" href="regest.jsp">注册</a>
<%
} 
		    else
		        {
		              int userid=(Integer)session.getAttribute("id");
		              int cartNum=cs.getALL(userid);
			                out.println( "欢迎您! "+username  );
			                out.println("<a href='memberzone.jsp' role='button' class='btn btn-success' >个人中心</a>");
			                out.println("<a href='cartlist.jsp' data-placement='bottom' role='button' class='btn btn-warning' data-toggle='tooltip' title=''>我的购物车"+cartNum+"</a>");
			                out.println( "<a href='destroySession.jsp' role='button' class='btn btn-danger' >安全退出</a>" );
		}
%>






</p>
	   </div>   
         </div>
            </div>
              </div>
<%
int dishesid = Integer.parseInt(request.getParameter("id"));

DishesService ds = new DishesService();


 %>

    <div class="container">
       <div class="row-fluid">
          <div class="span12">
     <p class="text-info"  style="font-size: 40px; margin-bottom: 30px; padding-left: 30px;"><%=ds.getDishesDetail(dishesid).getName() %></p>
    <div class="row-fluid">
    <div class="span6"  style="width: 470px; padding-left: 30px;">
     <img src="../<%=ds.getDishesDetail(dishesid).getPicture()%>" class="img-polaroid" style="width:300px;height:300px;" />
    <div class="row-fluid">
    </div>
    </div>
    <div class="span6">
     <p class="text-warning" style="font-weight:blod;font-size:30px;">菜品信息</p><br/>
    <div class="span6"style="margin-bottom:10px;" >  
    <div class="span5">
          <p class="text-info"  style="font-weight:blod;font-size:25px;"> 菜品种类</p>
    </div>
    <div class="span5">
     <p style="font-weight:blod;font-size:20px;"><%=ds.getType(ds.getDishesDetail(dishesid).getType()).getName() %></p>
    </div>
    </div><br/>
    <div class="span6"style="margin-bottom:10px;">
    <div class="span5">
          <p class="text-info"  style="font-weight:blod;font-size:25px;"> 菜品材料</p>
    </div>
    <div class="span5">
     <p style="font-size: 20px; width: 500px;"><%=ds.getDishesDetail(dishesid).getQuality()%></p>
    </div>
    </div><br/>
    <div class="span6" style="margin-bottom:10px;">
    <div class="span5">
          <p class="text-info"  style="font-weight:blod;font-size:25px;"> 菜品介绍</p>
    </div>
    <div class="span5">
     <p style="font-size: 20px; width: 500px;"><%=ds.getDishesDetail(dishesid).getDetail()%></p>
    </div>
    </div><br/>
    <div class="span6"style="margin-bottom:10px;">
        <div class="span5">
          <p class="text-info"  style="font-weight:blod;font-size:25px;"> 菜品价格</p>
    </div>
    <div class="span5">
     <p style="font-size: 20px; width: 100px;"><%=ds.getDishesDetail(dishesid).getPrice()%>元/份</p>
    </div>
    </div><br/>
    <%
    if(ds.getDishesDetail(dishesid).getSale()!=10){
    out.println("<div class='span6' style='margin-bottom:10px;'>");
    out.println("<div class='span5'><p class='text-info'  style='font-weight:blod;font-size:25px;'>菜品折扣</p></div>");
    out.println("<div class='span5'><p style='font-size: 20px; width: 100px;'>"+ds.getDishesDetail(dishesid).getSale()+"折</p><div>");
    out.println("</div<br/>");
    }
    %>
     <div class="span6" style="margin-top:20px;"><button style="float:left;" class="btn btn-danger" type="button" onclick=add("../action/websiteAction/orderAction.jsp?dishesId=<%=ds.getDishesDetail(dishesid).getId()%>&type=<%=ds.getDishesDetail(dishesid).getType()%>")>加入菜单</button></div><br/>
    </div>
    </div>
    </div>
    </div>
    <div class="span12" style="margin-top:50px;">
    <p class="text-warning" style="font-weight:blod;font-size:30px;margin-bottom:30px;">菜品评价</p><br/>
        <div class="span9">
    <%
    request.setCharacterEncoding("utf-8");
	ReviewService rs=new ReviewService();
	
	List<DishesReview> reviewlist = rs.getDishesReview(dishesid);//按参数查询
	SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	for(int i=0,length=reviewlist.size();i<length;i++){
		reviewlist.get(i).setDate(df.format(reviewlist.get(i).getTime()));
	}	
  %> 
  <table class="table table-hover">
      <tr>
        <td >评论时间</td>
        <td >用户名</td>
        <td >色彩</td>
        <td >香味</td>
        <td >味道</td>
        <td >评价内容</td>
      </tr>
  <%
  for (DishesReview re : reviewlist) {
	out.println("<input type='hidden' name='id' value='"+re.getId()+"'>");
	out.println("<tr><td>"+re.getDate()+"</td>");
    MemberService ms=new MemberService();
    out.println("<td>"+ms.getInfo(re.getUserid()).getUsername()+"</td>");
    int s=re.getColor();
    if(s==1){
    out.println("<td>优</td>");
    }
    else if(s==2){
    out.println("<td>中</td>");
    }
    else if(s==3) out.println("<td>差</td>");
	
	int a=re.getSmell();
    if(a==1){
    out.println("<td>优</td>");
    }
    else if(a==2){
    out.println("<td>中</td>");
    }
    else if(a==3)  out.println("<td>差</td>");
    
    int d=re.getTaste();
    if(d==1){
    out.println("<td>优</td>");
    }
    else if(d==2){
    out.println("<td>中</td>");
    }
    else if(d==3) out.println("<td>差</td>");
    
	out.println("<td><div align='center'>"+re.getContent()+"</div></td></tr>");
	
	
	}
	
%>
      </table>
    </div>
    </div>
    <form id="form" action="../action/websiteAction/addDishesReview.jsp" method="post">
    <input type="hidden" name="dishesid" value=<%=ds.getDishesDetail(dishesid).getId()%>>
    <div class="span12"style="margin-top:60px;">
<div class="span5"style="width:75px;">
<p class="text-error" style="font-weight:fold;font-size:20px;">色彩</p>
</div>
<div class="span2">
<label class="radio inline">
<input type="radio" name="color" id="color" value="1" >
优
</label>
<label class="radio inline">
<input type="radio" name="color" id="color" value="2">
中
</label>
<label class="radio inline">
<input type="radio" name="color" id="color" value="3">
差
</label>

</div>
</div><br/>
    <div class="span12"style="margin-top:20px;">
<div class="span5"style="width:75px;">
<p class="text-error" style="font-weight:fold;font-size:20px;">香味</p>
</div>
<div class="span2">
<label class="radio inline">
<input type="radio" name="smell" id="smell" value="1" >
优
</label>
<label class="radio inline">
<input type="radio" name="smell" id="smell" value="2">
中
</label>
<label class="radio inline">
<input type="radio" name="smell" id="smell" value="3">
差
</label>

</div>
</div><br/>
    <div class="span12"style="margin-top:20px;">
<div class="span5"style="width:75px;">
<p class="text-error" style="font-weight:fold;font-size:20px;">味道</p>
</div>
<div class="span2">
<label class="radio inline">
<input type="radio" name="taste" id="taste" value="1" >
优
</label>
<label class="radio inline">
<input type="radio" name="taste" id="taste" value="2">
中
</label>
<label class="radio inline">
<input type="radio" name="taste" id="taste" value="3">
差
</label>

</div>
</div><br/>
<div class="span7"style="margin-top:20px;">
<div class="span5"style="width:85px;">
<p class="text-error" style="font-weight:fold;font-size:20px;">具体内容</p>
</div>

<textarea id="review" rows="4" style="width:400px;border:2px solid #e8e;" name="content" onkeyup="textnum();" placeholder="你可以在这里输入对此菜品的评价,但是只允许输入50字以内"></textarea><br/>
<span id="reviewbot" style="float:right;margin-right:250px;">当前已输入：<span id="textnum"></span>字符，还可以输<span id="textleft"></span>字符<span id="msg" style="margin-left:20px;"></span></span>
<script>
	function textnum(){
		var p=$("#review").val();
		$("#textnum").html(p.length);
		$("#textleft").html(50-p.length);
		if(p.length>50){
			$("#review").val(p.substring(0,50))
			$("#textnum").html($("#review").val().length);
			$("#textleft").html(50-$("#review").val().length);
			$("#msg").html("<font color='red'>只允许输入50字</font>");
		}

	}
</script>
</div>
<div class="span6"style="margin-top:20px;width:500px;">
<button class="btn btn-large btn-primary" type="button" id="ok" style="float:right;">确定</button>
</div>
</form>
<div class="span12" style="height:200px;"></div>
    
    </div>
  </body>
</html>
